home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Languguage OS 2
/
Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO
/
gnu
/
nihcl-30.lha
/
nihcl-3.0
/
ex
/
ex13-11.c
< prev
next >
Wrap
C/C++ Source or Header
|
1990-05-15
|
1KB
|
40 lines
// ex13-11.c -- Limitation of Object I/O
// $Header: /afs/alw.nih.gov/unix/sun4_40c/usr/local/src/nihcl-3.0/share/ex/RCS/ex13-11.c,v 3.0 90/05/15 22:44:35 kgorlen Rel $
#include <fstream.h>
#include <osfcn.h>
#include "QLink.h"
#include "LandVhcl.h"
#include "OIOnih.h"
main()
{
QLink* qlp = new LandVhcl(4.1, 12.0);
Link* lp = (QLink*) new LandVhcl(4.2, 12.0);
ofstream outstrm("badfile",ios::out,0664); // UNIX protection
// mode 0664
if (outstrm.fail()) {
cerr << "Failed to open badfile";
exit(1);
}
OIOnihout out(outstrm);
qlp->storeOn(out);
lp->storeOn(out);
outstrm.close();
LandVhcl* t = LandVhcl::castdown((Object*)qlp);
delete t;
t = LandVhcl::castdown((Object*)lp);
delete t;
ifstream instrm("badfile");
if (instrm.fail()) {
cerr << "Failed to open badfile\n";
exit(1);
}
OIOnihin in(instrm);
qlp = QLink::readFrom(in); // OK
cout << *qlp << endl;
lp = Link::readFrom(in); // error: ambiguous downward cast
}